/**
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
*
* MpmProjectChangeServiceAuto
* 项目立项信息变更
*
* 修改纪录
* 2021-07-14 版本：1.0 wudaliang 创建。
* @version 版本：1.0
* @author 作者：wudaliang
* 创建日期：2021-07-14
*/

package com.topscomm.mpm.service.impl.auto;

import javax.annotation.Resource;
import com.topscomm.basic.IBasicDao;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.tap.common.DatacodeCache;

import java.text.DecimalFormat;
import java.util.Map;
import com.topscomm.mpm.*;
import com.topscomm.mpm.pojo.MpmProjectChangeEntity;
import com.topscomm.mpm.dao.IMpmProjectChangeDao;


public class MpmProjectChangeServiceAuto extends MpmService<MpmProjectChangeEntity,IMpmProjectChangeDao> {

	/**
	 * @author: wudaliang
	 * @date: 2021-07-14
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("flowid") != null) {
			temp = mapRow.get("flowid").toString();
			mapRow.put("dispflowid", datacodeCache.getValueDynamic("ApprovalFlow_MpmProject", temp, "id", "name"));
		}
		if (mapRow.get("state") != null) {
			temp = mapRow.get("state").toString();
			mapRow.put("dispstate", datacodeCache.getValueDynamic("TapApprovalBillState", temp, "code", "name"));
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("projectlevel2") != null) {
			temp = mapRow.get("projectlevel2").toString();
			mapRow.put("dispprojectlevel2", datacodeCache.getValueDynamic("MpmProjectLevel", temp, "code", "name"));
		}
		if (mapRow.get("projectsource2") != null) {
			temp = mapRow.get("projectsource2").toString();
			mapRow.put("dispprojectsource2", datacodeCache.getValueDynamic("ProjectSource", temp, "code", "name"));
		}
		// 处理手机端金额展示问题
		if (mapRow.get("projectmoney") != null) {
			temp = mapRow.get("projectmoney").toString();
			String str=new DecimalFormat("#,###.00").format(ConvertUtil.convertToDouble(temp));
			if (str.startsWith(".")){
				// 补零
				str = "0"+str;
			}
			mapRow.put("dispprojectmoney",str+"万元");
		}
		if (mapRow.get("projectendmoney2") != null) {
			temp = mapRow.get("projectendmoney2").toString();
			String str=new DecimalFormat("#,###.00").format(ConvertUtil.convertToDouble(temp));
			if (str.startsWith(".")){
				// 补零
				str = "0"+str;
			}
			mapRow.put("dispprojectendmoney2", str+"万元");
		}
		if (mapRow.get("participatemoney2") != null) {
			temp = mapRow.get("participatemoney2").toString();
			String str=new DecimalFormat("#,###.00").format(ConvertUtil.convertToDouble(temp));
			if (str.startsWith(".")){
				// 补零
				str = "0"+str;
			}
			mapRow.put("dispparticipatemoney2",str+"万元");
		}
	}

	@Override
	@Resource(name = "mpmProjectChangeDao")
	public void setDao(IBasicDao<MpmProjectChangeEntity> dao) {
		super.setDao(dao);
	}
}
